pkgname="tarantool"
pkgver=""
pkgrel="0"
pkgdesc="Tarantool is an in-memory computing platform consisting of a database and an application server"
maintainer="Ilya Konyukhov <i.konyukhov@tarantool.org>"
license="BSD-2-Clause"
arch="all"
source=""
giturl="https://github.com/tarantool/tarantool.git"
url="https://github.com/tarantool/tarantool"
depends="g++ libstdc++ readline openssl yaml lz4 binutils ncurses lua tar zip zlib libunwind icu ca-certificates"
makedepends="gcc cmake file readline-dev openssl-dev yaml-dev bsd-compat-headers lz4-dev zlib-dev binutils-dev ncurses-dev lua-dev musl-dev make git libunwind-dev autoconf automake libtool linux-headers icu-dev"

subpackages="$pkgname-dev $pkgname-dbg $pkgname-doc"

builddir="$srcdir"/"$pkgname-$pkgver"

prepare() {
    default_prepare
}

build() {
    cd "$builddir"

    if [ "${GC64}" = "true" ]; then
        GC64=ON
    fi

    cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-RelWithDebInfo} \
          -DENABLE_DIST:BOOL=ON \
          -DLUAJIT_DISABLE_SYSPROF:BOOL=ON \
          -DLUAJIT_ENABLE_GC64:BOOL=${GC64:-OFF} \
          -DCMAKE_INSTALL_PREFIX=/usr \
          -DCMAKE_INSTALL_SYSCONFDIR=/etc \
          -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
          .
    make -C "$builddir" -j || return 1

    return 0
}

package() {
    mkdir -p "$pkgdir"

    make -C "$builddir" DESTDIR="$pkgdir" install
    make -C "$builddir"/src/lib/small DESTDIR="$pkgdir" install
    make -C "$builddir"/src/lib/msgpuck DESTDIR="$pkgdir" install

    make -C "$builddir/src/lib/msgpuck" clean
    make -C "$builddir/src/lib/small" clean
    make -C "$builddir" clean

    return 0
}
